/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo1022;
import demo1021.*;
import java.sql.*;

/**
 *
 * @author Administrator
 */
public class InsertDemo {
    public static void main(String args[]){
        Connection conn=null;
        PreparedStatement pstat=null;
       
        try{
        Class.forName("com.mysql.jdbc.Driver");//
        String url="jdbc:mysql://localhost:3306/st";
        conn=DriverManager.getConnection(url, "root", "root");
        pstat=conn.prepareStatement("insert into students "
                + "values(?,?,?,?,?)");
        pstat.setString(1,"199909");
        pstat.setString(2,"li");
        pstat.setInt(3,90);
        pstat.setInt(4,91);
        pstat.setInt(5,90);
        int count=pstat.executeUpdate();
           System.out.println(count);
           if(count>0){
               System.out.println("更新成功");
           }else{
               System.out.println("更新失败");
           }
//              pstat.setString(1,"199910");
//        pstat.setString(2,"wang");
//        pstat.setInt(3,90);
//        pstat.setInt(4,91);
//        pstat.setInt(5,90);
//         count=pstat.executeUpdate();
//           System.out.println(count);
//           if(count>0){
//               System.out.println("更新成功");
//           }else{
//               System.out.println("更新失败");
//           }
      
        }catch(ClassNotFoundException e){
            System.out.println(e.getMessage());
        }
        catch(SQLException e){
            System.out.println(e.getMessage());
            
        }
    }
    
}
